<template>
  <div>
    <a-carousel arrows autoplay>
      <div v-for="(item, idx) in carousel" :key="idx">
        <img :src="item" alt="" class="swiper-img" />
      </div>
    </a-carousel>
    <!-- 热度文章 -->
    <div class="hotContent">
      <a-row type="flex" justify="space-between">
        <a-col
          v-for="(item, idx) in hotarticles"
          :key="item.id"
          :lg="{ span: 5 }"
          :xs="{ span: 11 }"
        >
          <hot-card :info="item"></hot-card>
        </a-col>
      </a-row>
    </div>
    <!-- 切换tab -->
    <a-row>
      <a-col>
        <a-tabs default-active-key="0">
          <a-tab-pane key="0" tab="最新文章">
            <ArticleType :type="0" />
          </a-tab-pane>
          <a-tab-pane key="1" tab="热门文章">
            <ArticleType :type="1" />
          </a-tab-pane>
          <a-tab-pane key="2" tab="评论最多">
            <ArticleType :type="2" />
          </a-tab-pane>
          <a-tab-pane key="3" tab="点赞最多">
            <ArticleType :type="3" />
          </a-tab-pane>
        </a-tabs>
      </a-col>
    </a-row>
  </div>
</template>

<script>
import ArticleType from "./ArticleTypeView.vue";
import HotCard from "@/components/client/HotCard.vue";

export default {
  mounted() {
    this.$bus.$on("hotArticle", (hotArticle) => {
      this.hotarticles = hotArticle;
    });
  },
  beforeDestroy() {
    this.$bus.$off("hotArticle");
  },
  data() {
    return {
      carousel: [
        require("@/assets/0.jpg"),
        require("@/assets/0.jpg"),
        require("@/assets/0.jpg"),
        require("@/assets/0.jpg"),
      ],
      // 热度文章
      hotarticles: [],
      // 公告
      notice: "",
    };
  },
  components: { HotCard, ArticleType },
};
</script>

<style scoped>
.ant-tabs {
  overflow: unset;
}
.ant-carousel >>> .slick-slide {
  text-align: center;
  height: 335px;
  line-height: 335px;
  overflow: hidden;
}

.ant-carousel >>> .custom-slick-arrow {
  width: 25px;
  height: 25px;
  font-size: 25px;
  color: #fff;
  background-color: rgba(31, 45, 61, 0.11);
  opacity: 0.3;
}
.ant-carousel >>> .custom-slick-arrow:before {
  display: none;
}
.ant-carousel >>> .custom-slick-arrow:hover {
  opacity: 0.5;
}
@media (max-width: 768px) {
  .ant-carousel >>> .slick-slide {
    text-align: center;
    height: 180px !important;
    line-height: 335px;
    overflow: hidden;
  }
  .ant-carousel >>> .slick-slide img {
    height: 180px !important;
    width: 100%;
  }
}
.ant-carousel >>> .slick-slide img {
  height: 335px;
}
.hotContent {
  margin-top: 10px;
}
.tabs_notice {
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 1.4;
  text-align: center;
}
.tabs_notice a:hover {
  color: #9999ff;
}

.tabs_notice a {
  margin-left: 5px;
  color: #909399;
  line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.35s;
}
</style>
